//日期补零
function dateAddZero(date,spe){
  spe = spe||"-";
  let arr = date.split(spe);
  if(arr[1]-0<10){
    arr[1] = "0"+arr[1];
  }
  if(arr[2]-0<10){
    arr[2] = "0"+arr[2];
  }
  return arr.join(spe)
}

//某个月的最后一天
function getMonthLastDay(date){//2018-08或者['2018','08']
  let arr = [];
  if(Array.isArray(date)){
    arr = date
  }else if(typeof date=="string"){
    arr = date.split('-')
  }
  let date1 = new Date(arr.join('/')+'/01');
  date1.setMonth(date1.getMonth()+1);
  date1.setDate(0);
  let last_day = date1.getDate();
  return last_day
}

//日期格式
const formatDateFun=function (date,fmt='y/M/d h:m:s'){
	if(!date){
    return '';
  }else if(date&&Object.prototype.toString.call(date)!='[object Date]'){
    if(new Date(date).getDate()){
      date=new Date(date);
    }else{
      return date;
    }
  }
  let o = {
    "y+": date.getFullYear(),
    "M+": date.getMonth() + 1,
    "d+": date.getDate(),
    "h+": date.getHours(),
    "m+": date.getMinutes(),
    "s+": date.getSeconds(),
    "q+": Math.floor((date.getMonth() + 3)/3),
    "S+": date.getMilliseconds()
  };
  [o['M+'],o['d+'],o['h+'],o['m+'],o['s+']]=[o['M+'],o['d+'],o['h+'],o['m+'],o['s+']].map(v=>v<10?('0'+v):v);
  let str = fmt, reg = null;
  for(let key in o) {
    reg = new RegExp(key);
    str = str.replace(reg, o[key]);
  }
  return str;
}